package com.xx.job.controller.server;

import com.xx.job.controller.base.BaseController;
import com.xx.job.service.server.ServerService;
import io.swagger.annotations.Api;
import org.hyperic.sigar.SigarException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Api(tags = "服务器信息")
@RestController
public class ServerController extends BaseController {

    @Autowired
    private ServerService ServerService;

    @RequestMapping("/api/v1/setting/serverInfo")
    public Map<String,Object> getServer(HttpServletRequest request) throws SigarException {
        Map<String,Object> map = new HashMap<>();
        map.put("code",200);
        map.put("cpu",ServerService.getCpu());
        map.put("disk",ServerService.getDisk());
        map.put("mem",ServerService.getMem());
        map.put("os",ServerService.getOs(request));
        map.put("msg","");
        return  map;
    }
}
